﻿#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
#include<map>
#include<set>
using namespace std;

int main()
{
	/*multiset<int> s{ 1,2,5,9,2,4,7 };
	for (auto e : s)
	{
		cout << e << " ";
	}
	cout << endl;

	int x = 0;
	cin >> x;
	auto pos = s.find(x);
	while (pos != s.end() && *pos == x)
	{
		cout << *pos << " ";
		++pos;
	}
	cout << endl;

	cout << s.count(x) << endl;

	s.erase(x);
	for (auto e : s)
	{
		cout << e << " ";
	}
	cout << endl;*/

	map<string, string> s{ {"left", "左边"}, {"right", "右边"},{"insert", "插入"},{ "string", "字符串" } };

	auto it = s.begin();
	while (it != s.end())
	{
		cout << it->first << ':' << it->second << " ";

		++it;
	}
	cout << endl;

	//1.插入的四个方法：
	pair<string, string> kv1("first","第一个");
	s.insert(kv1);

	s.insert(pair<string, string>("second", "第二个"));

	s.insert(make_pair("sort", "排序"));

	s.insert({ "auto","自动的" });

	for (const auto& e : s)
	{
		cout << e.first << ':' << e.second << " ";
	}
	cout << endl;

	s.insert({ "left","左边，剩余" });//没有插入

	it = s.begin();

	//it->first += 'x';//key不支持改；
	//it->second += 'x';
	//cout << it->first << ':' << it->second << endl;

	string str;
	/*while (cin >> str)
	{
		auto ret = s.find(str);
		if (ret!=s.end())
		{
			cout << str << "->" << ret->second << endl;
		}
		else
		{
			cout << "没有这个单词" << endl;
		}

	}*/

	//cin >> str;
	//s.erase(str);
	/*it = s.find(str);
	if(it!=s.end())
	{
		s.erase(it);
	}

	for (const auto& e : s)
	{
		cout << e.first << ':' << e.second << " ";
	}
	cout << endl;*/

	/*if (s.count(str))
	{
		cout << "存在" << endl;
	}
	else
	{
		cout << "不存在" << endl;
	}*/

	auto itlow = s.lower_bound("first");
	auto itup = s.upper_bound("right");

	s.erase(itlow, itup);
	for (const auto& e : s)
	{
		cout << e.first << ":" << e.second << " ";
	}
	cout << endl;
	return 0;
}